package phantri.uit.menunhahang;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import phantri.uit.menunhahang.Param;
import phantri.uit.menunhahang.DouongObj;

public class GetDouong {

	public static final String WSM_DOUONG_GETDUONG = "GetDouong";
	private static String METHOD_NAME = "GetDouong";
	private static String NAMESPACE = "http://tempuri.org/";
	private static String SOAP_ACTION = NAMESPACE + METHOD_NAME;
	private static final String URL = "http://10.0.2.2/MenuServices/Service1.asmx";

	public List<DouongObj> getDouong() {
		int n = 0;
		//Object[] resultSoap = new Object[100];
		SoapObject soap;
		List<DouongObj> listDouong = new ArrayList<DouongObj>();
		try {
			SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
			SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
					SoapEnvelope.VER11);
			envelope.dotNet = true;
			envelope.setOutputSoapObject(request);
			HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
			androidHttpTransport.call(SOAP_ACTION, envelope);

			soap = (SoapObject) envelope.getResponse();
			n = soap.getPropertyCount();
			for (int i = 0; i < n; i++) {
				DouongObj model = new DouongObj();
				model.parse(soap.getProperty(i));
				listDouong.add(model);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return listDouong;
	}
}
